<%--
  Created by IntelliJ IDEA.
  User: WYX
  Date: 2024/4/12
  Time: 9:24
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" import="java.util.*" %>
<%@taglib prefix="getWords" tagdir="/WEB-INF/tags/experimentReport" %>
<html>
<head>
    <title>实验三：解析单词</title>
</head>
<body>
<form action="" method="post">
    <label for="textAreaId">输入英文短语</label><br>
    <textarea name="txt" id="textAreaId" cols="30" rows="10"></textarea><br>
    <input type="submit" name="submit" value="提交"><br>
    <%
        String txt = request.getParameter("txt");
        if (txt != null) {
    %>
    <getWords:three word="<%=txt%>"/>
    <%
        List<String> list = new ArrayList<String>(words);
        out.print("使用了" + list.size() + "个单词：<br>");
        Collections.sort(list);
        out.print("字典序：" + list + "<br>");
        list.sort(Comparator.comparingInt(String::length));
        out.print("长度升序：" + list + "<br>");
        list.sort((a, b) -> Integer.compare(b.length(), a.length()));
        out.print("长度降序：" + list + "<br>");
        }
    %>
</form>
</body>
</html>
